/* ==========================================================================
   ILOVEFREE样式迁移系统 - 从UIKit到现代化设计系统
   迁移网页A的视觉设计到网页B
   ========================================================================== */

/* CSS变量映射表 - 网页A色彩系统映射到网页B变量系统 */
:root {
    /* 网页A原始色彩映射 */
    --ilovefree-blue: #0396FF;
    --ilovefree-light: #b3e0fa;
    --ilovefree-accent: #00a8e6;
    --ilovefree-gray: #999;
    --ilovefree-dark: #333;
    --ilovefree-white: #fff;
    --ilovefree-bg-light: #f1f1f1;

    /* 网页A特色渐变 */
    --ilovefree-gradient: radial-gradient(circle at 0% 20%, var(--ilovefree-blue), var(--ilovefree-light));
    --ilovefree-gradient-hover: radial-gradient(circle at 0% 20%, var(--ilovefree-accent), var(--ilovefree-blue));

    /* 布局间距映射 */
    --ilovefree-title-margin: 35px 0px 0px 0px;
    --ilovefree-tag-margin: 35px 0px 12px 0px;
    --ilovefree-card-margin: 20px 0px 0px 0px;
    --ilovefree-divider-margin: 0px 0px 10px 0px;

    /* 尺寸映射 */
    --ilovefree-icon-width: 3px;
    --ilovefree-badge-size: 18px;
    --ilovefree-font-shrink: 0.7;

    /* 过渡动画 */
    --ilovefree-transition: all 0.25s ease;
    --ilovefree-transition-fast: all 0.15s ease;
}

/* 样式隔离命名空间 */
.ilovefree-migration {
    /* 所有迁移样式都包含在这个命名空间下，避免冲突 */
}

/* ==========================================================================
   分类标题样式迁移 (.title_p → .category-header)
   ========================================================================== */

.category-header {
    margin: var(--ilovefree-title-margin);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
    min-height: 40px;
}

.category-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 0;
}

.category-icon {
    width: var(--ilovefree-icon-width);
    height: 24px;
    background: var(--ilovefree-gradient);
    border-radius: 2px;
    transition: var(--ilovefree-transition);
    flex-shrink: 0;
}

.category-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: inline;
    font-family: "Microsoft YaHei", "Hiragino Sans GB", "STHeiti", "Heiti SC", sans-serif;
}

.category-name span {
    background: var(--ilovefree-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.category-line {
    display: none;
}

/* ==========================================================================
   标签系统样式迁移 (.uk-tab → .tags-container)
   ========================================================================== */

.tags-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0;
    flex-shrink: 1;
    min-width: 0;
    margin-right: 0;
    justify-content: flex-end;
    align-self: center;
    height: 100%;
}

.tag-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-right: 0.5rem;
}

.tag-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--ilovefree-bg-light);
    border-radius: var(--radius-full);
    background: var(--ilovefree-white);
    color: var(--ilovefree-gray);
    font-size: 0.75rem;
    font-weight: 400;
    cursor: pointer;
    transition: var(--ilovefree-transition);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    flex-shrink: 0;
}

.tag-btn:hover {
    border-color: var(--ilovefree-blue);
    color: var(--ilovefree-blue);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(3, 150, 255, 0.2);
}

.tag-btn.active {
    background: var(--ilovefree-gradient);
    border-color: var(--ilovefree-blue);
    color: var(--ilovefree-white);
    box-shadow: 0 4px 15px rgba(3, 150, 255, 0.3);
    font-weight: 500;
}

.tag-btn.active:hover {
    background: var(--ilovefree-gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(3, 150, 255, 0.4);
}

.tag-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 500px;
    font-size: 10px;
    line-height: 12px;
    font-weight: 400;
    box-sizing: border-box;
    transition: var(--ilovefree-transition-fast);
    flex-shrink: 0;
}

.tag-btn:not(.active) .tag-count {
    background: var(--ilovefree-white);
    color: var(--ilovefree-gray);
    border: 1px solid var(--ilovefree-bg-light);
}

/* 字体缩小效果 - 对应原fontshrink类 */
.font-shrink {
    transform: scale(var(--ilovefree-font-shrink));
    transform-origin: center;
    display: inline-block;
}

/* ==========================================================================
   导航卡片样式迁移 (.uk-panel-box → .nav-link)
   ========================================================================== */

.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    position: relative;
}

.nav-link {
    position: relative;
    overflow: hidden;
    transition: var(--ilovefree-transition);
}

.nav-link {
    /* margin: var(--ilovefree-card-margin); */
    text-align: center;
    padding: 0.75rem;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: var(--ilovefree-transition);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.nav-link:hover {
    background: var(--bg-glass-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--ilovefree-blue);
}

.nav-link img {
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: cover;
    margin-bottom: 0.5rem;
}

.nav-link h4 {
    font-weight: 700;
    font-size: 1rem;
    margin: 0.5rem 0.25rem 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    font-family: "Microsoft YaHei", "Hiragino Sans GB", "STHeiti", "Heiti SC", sans-serif;
}

.nav-link p {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin: 0.25rem;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    flex: 1;
}

/* 徽章样式 - 对应原uk-badge */
.nav-badge {
    background: var(--ilovefree-white);
    color: var(--ilovefree-gray);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 400;
    margin-top: 0.25rem;
    display: inline-block;
    text-shadow: none;
    border: 1px solid var(--ilovefree-bg-light);
}

/* ==========================================================================
   UIKit组件替换和兼容性适配
   ========================================================================== */

/* 移除原有UIKit样式的影响 */
.uk-tab,
.uk-panel-box,
.uk-grid,
.uk-badge {
    /* 重置可能冲突的UIKit样式 */
    all: unset;
}

/* 网格系统替换 */
.uk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.uk-width-medium-1-5 {
    grid-column: span 1;
}

.uk-width-medium-1-4 {
    grid-column: span 1;
}

.uk-width-medium-1-3 {
    grid-column: span 1;
}

@media (min-width: 768px) {
    .uk-width-medium-1-5 {
        grid-column: span 1;
    }

    .uk-width-medium-1-4 {
        grid-column: span 1;
    }

    .uk-width-medium-1-3 {
        grid-column: span 1;
    }
}

@media (min-width: 1024px) {
    .nav-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .uk-width-medium-1-5 {
        grid-column: span 1;
    }

    .uk-width-medium-1-4 {
        grid-column: span 1;
    }

    .uk-width-medium-1-3 {
        grid-column: span 2;
    }
}

/* ==========================================================================
   响应式布局适配
   ========================================================================== */

@media (max-width: 1024px) {
    .category-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .category-line {
        display: none;
    }

    .tags-container {
        margin-left: 0;
        margin-right: 0;
        flex-wrap: wrap;
        max-width: 100%;
        justify-content: flex-end;
        align-self: center;
        height: auto;
        min-height: 32px;
    }
}

    .nav-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.75rem;
    }
}

/* 中等屏幕 - 调整标签位置 */
@media (max-width: 1200px) {
    .category-title {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .category-name {
        font-size: 1.25rem;
    }

    .tag-btn {
        padding: 0.375rem 0.625rem;
        font-size: 0.8rem;
    }

    .nav-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.5rem;
    }

    .nav-link {
        padding: 0.5rem;
    }

    .nav-link img {
        max-height: 100px;
    }

    .nav-link h4 {
        font-size: 0.875rem;
    }

    .nav-link p {
        font-size: 0.7rem;
        -webkit-line-clamp: 1;
    }
}

@media (max-width: 480px) {
    .category-header {
        margin: 1.5rem 0 0 0;
    }

    .category-name {
        font-size: 1.125rem;
    }

    .tags-container {
        margin: 1rem 0 0.75rem 0;
        gap: 0.375rem;
    }

    .tag-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .nav-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .nav-link {
        margin: 0.75rem 0 0 0;
        padding: 0.375rem;
        min-height: 120px;
    }

    .nav-link img {
        max-height: 80px;
    }
}

/* ==========================================================================
   动画和交互效果
   ========================================================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-link {
    animation: fadeInUp 0.6s ease forwards;
}

.nav-link:nth-child(1) { animation-delay: 0.1s; }
.nav-link:nth-child(2) { animation-delay: 0.2s; }
.nav-link:nth-child(3) { animation-delay: 0.3s; }
.nav-link:nth-child(4) { animation-delay: 0.4s; }
.nav-link:nth-child(5) { animation-delay: 0.5s; }

/* 过滤动画 */
.nav-link.filtering {
    opacity: 0.3;
    transform: scale(0.95);
    transition: all 0.3s ease;
}

.nav-link.hidden {
    opacity: 0;
    transform: scale(0.8);
    display: none;
}

/* ==========================================================================
   辅助类和工具样式
   ========================================================================== */

/* 兼容原UIKit类名 */
.uk-panel-box {
    @extend .nav-link;
}

.uk-panel-hover {
    @extend .nav-link:hover;
}

.uk-badge-notification {
    @extend .tag-count;
}

.uk-badge-hui {
    @extend .nav-badge;
}

.uk-grid-divider {
    @extend .category-line;
}

/* 回滚样式类 */
.rollback-mode .category-header {
    /* 恢复原始title_p样式 */
    margin: var(--ilovefree-title-margin);
    position: relative;
}

.rollback-mode .tags-container {
    /* 恢复原始uk-tab样式 */
    margin: var(--ilovefree-tag-margin);
}

.rollback-mode .nav-link {
    /* 恢复原始uk-panel-box样式 */
    margin: var(--ilovefree-card-margin);
    text-align: center;
    padding: 6px;
}

/* 性能优化 */
.nav-link,
.tag-btn {
    will-change: transform;
}

.nav-link img {
    loading: lazy;
}

/* 打印样式 */
@media print {
    .category-header,
    .tags-container,
    .nav-grid {
        display: block;
    }

    .nav-link {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}